Page({
  data: {
    "video": "https://vod.youlai.cn/7fa3a340659071edbfb00675a0ec0102/16808ffbd4ff4a5b864ec42235df1a54-3b49a6ef048f95a28ef2c9278fb8b1da-sd.mp4", // 示例视频链接
    "img": "",   // 示例图片链接
    "switchs": [],                            // 开关数组，需要在请求返回数据后填充
    "subfolders": [
      {
        "title": "子文件夹1",
        "data": [
          { "id": 1, "question": "问心脏病突发时，究竟是阿司匹林管用，还是硝酸甘油管用呢？", "answer": "对于临床常见的急性心肌缺血，如果说阿司匹林是“救命药”，它对急性心肌梗死患者早期应用可减少约30%的死亡，而硝酸甘油则可称为“对症药”，舌下含服可以迅速缓解患者出现的心绞痛症状。" },
          { "id": 2, "question": "硝酸甘油用法有哪些禁忌？", "answer": "低血压患者或平常血压偏低的患者应慎用硝酸甘油，因为其会使血压降得更低，尤其在体位突然变动时更易发生。" }
          // 添加更多问题和答案
        ]
      },
      // 添加更多子文件夹
    ],
    "scenes": [
      { "title": "场景1", "content": "场景1的内容" },
      { "title": "场景2", "content": "场景2的内容" }
      // 添加更多场景
    ],
    "duration": 120, // 示例视频时长，单位秒
  },
  onLoad: function (options) {
    var that = this
    wx.request({
      url: options.aidurl,
      method:"GET",
      success:function(res){
        that.setData({
          "scenes": res.data.scenes,
          "subfolders": res.data.subfolders,
          "switchs": res.data.subfolders!=null ? Array(res.data.subfolders[0].data.length).fill(false):[],
          "video": (res.data.video == null || res.data.video == '') ? "" : (res.data.video.search("https")==0 ? res.data.video : "https://wx.all-help.com/static/html/" + res.data.video),
          "duration": (res.data.VideoDuration == null || res.data.VideoDuration=='') ? 0 : 60 * parseInt(res.data.VideoDuration)[0] + parseInt(res.data.VideoDuration)[1],
          "img": (res.data.videoImage == null || res.data.videoImage == "") ? "" : res.data.videoImage
        })
      }
    })
  },
  toggle:function(event){
    var index = event.currentTarget.id - 1
    var temparray = this.data.switchs
    var temp=!temparray[index]
    temparray[index]=temp
    this.setData({
      switchs:temparray
    })
  },
  phonecall: function (event) {
      wx.makePhoneCall({
        phoneNumber: event.currentTarget.id
      })
  }
});
